//
//  NotificatonSettingCell.swift
//  EasePods
//
//  Created by 李然 on 2024/5/7.
//

import UIKit
import EarbudsFunctions

class NotificatonSettingCell: TableViewCell {

    override func makeUI() {
        super.makeUI()
        
        backgroundColor = R.color.common_2_bg_page()

        contentView.addSubview(iconView)
        iconView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.leading.equalToSuperview().offset(20)
            make.size.equalTo(CGSize(width: 22, height: 22))
        }

        contentView.addSubview(titleL)
        titleL.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.leading.equalTo(iconView.snp.trailing).offset(8)
        }

        contentView.addSubview(switchView)
        switchView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSize(width: 56, height: 32))
            make.trailing.equalToSuperview().offset(-20)
        }
    }
    
    func bind(viewModel: NotificationCellViewModel) {
        self.iconView.image = viewModel.type.iconImage
        self.titleL.text = viewModel.type.title
        
        viewModel.isEnabled.asDriver().drive(switchView.rx.isOn).disposed(by: cellDisposeBag)
        switchView.rx.isOn.skip(1).bind(to: viewModel.switchChanged).disposed(by: cellDisposeBag)
    }

    lazy var iconView: ImageView = {
        let view = ImageView()

        return view
    }()

    lazy var titleL: Label = {
        let label = Label()
        label.font = Fonts.systemFont(ofSize: 14)
        label.textColor = R.color.common_3_text()
        return label
    }()

    lazy var switchView: CustomSwitchView = {
        let switchView = CustomSwitchView()
        return switchView
    }()

}


extension NotificationType {
    
    var iconImage: UIImage? {
        switch self {
        case .Phone: return R.image.ic_message_phone()
        case .Messages: return R.image.ic_message_messages()
        case .Wechat: return R.image.ic_message_wechat()
        case .QQ: return R.image.ic_message_qq()
        case .Facebook: return R.image.ic_message_facebook()
        case .Twitter: return R.image.ic_message_twitter()
        case .Instagram: return R.image.ic_message_instagram()
        case .Skype: return R.image.ic_message_skype()
        case .WhatsApp: return R.image.ic_message_whatsapp()
        case .Line: return R.image.ic_message_line()
        case .KakaoTalk: return R.image.ic_message_kakaotalk()
        case .Email: return R.image.ic_message_email()
        case .Messenger: return R.image.ic_message_messenger()
        case .Zalo: return R.image.ic_message_zalo()
        case .Telegram: return R.image.ic_message_telegram()
        case .Viber: return R.image.ic_message_viber()
        case .NateOn: return R.image.ic_message_nateon()
        case .Gmail: return R.image.ic_message_gmail()
        case .Calenda: return R.image.ic_message_calendar()
        case .DailyHunt: return R.image.ic_message_dailyhunt()
        case .Outlook: return R.image.ic_message_outlook()
        case .Yahoo: return R.image.ic_message_yahoo()
        case .Inshorts: return R.image.ic_message_inshorts()
        case .Phonepe: return R.image.ic_message_phonepe()
        case .Gpay: return R.image.ic_message_gpay()
        case .Paytm: return R.image.ic_message_paytm()
        case .Swiggy: return R.image.ic_message_swiggy()
        case .Zomato: return R.image.ic_message_zomato()
        case .Uber: return R.image.ic_message_uber()
        case .Ola: return R.image.ic_message_ola()
        case .ReflexApp: return R.image.ic_message_reflex()
        case .Snapchat: return R.image.ic_message_snapchat()
        case .YtMusic: return R.image.ic_message_ytmusic()
        case .YouTube: return R.image.ic_message_youtube()
        case .LinkEdin: return R.image.ic_message_linkedin()
        case .Amazon: return R.image.ic_message_amazon()
        case .Flipkart: return R.image.ic_message_flipkart()
        case .NetFlix: return R.image.ic_message_netflix()
        case .Hotstar: return R.image.ic_message_hotstar()
        case .AmazonPrime: return R.image.ic_message_amazonprime()
        case .GoogleChat: return R.image.ic_message_googlechat()
        case .Wynk: return R.image.ic_message_wynk()
        case .GoogleDrive: return R.image.ic_message_google_drive()
        case .Dunzo: return R.image.ic_message_dunzo()
        case .Gaana: return R.image.ic_message_gaana()
        case .MissCall: return R.image.ic_message_miss_call()
        case .WhatsAppBussiness: return R.image.ic_message_whatsapp_business()
        case .Dingtalk: return R.image.ic_message_dingtalk()
        case .Tiktok: return R.image.ic_message_tiktok()
        case .Lyft: return R.image.ic_message_lyft()
        case .Mail: return R.image.ic_message_mail()
        case .GoogleMaps: return R.image.ic_message_googlemaps()
        case .Slack: return R.image.ic_message_slack()
        case .MicrosoftTeams: return R.image.ic_message_microsoftteams()
        case .MormaiiSmartwatches: return R.image.ic_message_mormaiismartwatches()
        case .Reddit: return R.image.ic_message_reddit()
        case .Discord: return R.image.ic_message_discord()
        case .Calendar: return R.image.ic_message_calendar()
        case .Gojek: return R.image.ic_message_gojek()
        case .Lark: return R.image.ic_message_lark()
        case .Garb: return R.image.ic_message_grab()
        case .Shopee: return R.image.ic_message_shopee()
        case .Tokopedia: return R.image.ic_message_tokopedia()
        case .other: return R.image.ic_message_others()
        }
    }
    
    var title: String? {
        switch self {
        case .Phone: return R.string.localizable.setting_messages_phone_call()
        case .Messages: return R.string.localizable.setting_messages_sms()
        case .Wechat: return R.string.localizable.setting_messages_wechat()
        case .QQ: return R.string.localizable.setting_messages_qq()
        case .Facebook: return R.string.localizable.setting_messages_facebook()
        case .Twitter: return R.string.localizable.setting_messages_twitter()
        case .Instagram: return R.string.localizable.setting_messages_instagram()
        case .Skype: return R.string.localizable.setting_messages_skype()
        case .WhatsApp: return R.string.localizable.setting_messages_whatsapp()
        case .Line: return R.string.localizable.setting_messages_line()
        case .KakaoTalk: return R.string.localizable.setting_messages_kakaotalk()
        case .Email: return R.string.localizable.setting_messages_email()
        case .Messenger: return R.string.localizable.setting_messages_messenger()
        case .Zalo: return R.string.localizable.setting_messages_zalo()
        case .Telegram: return R.string.localizable.setting_messages_telegram()
        case .Viber: return R.string.localizable.setting_messages_viber()
        case .NateOn: return R.string.localizable.setting_messages_noteon()
        case .Gmail: return R.string.localizable.setting_messages_gmail()
        case .Calenda: return R.string.localizable.setting_messages_notification_calenda()
        case .DailyHunt: return R.string.localizable.setting_messages_dailyhunt()
        case .Outlook: return R.string.localizable.setting_messages_outlook()
        case .Yahoo: return R.string.localizable.setting_messages_yahoo()
        case .Inshorts: return R.string.localizable.setting_messages_inshorts()
        case .Phonepe: return R.string.localizable.setting_messages_phonepe()
        case .Gpay: return R.string.localizable.setting_messages_gpay()
        case .Paytm: return R.string.localizable.setting_messages_paytm()
        case .Swiggy: return R.string.localizable.setting_messages_swiggy()
        case .Zomato: return R.string.localizable.setting_messages_zomato()
        case .Uber: return R.string.localizable.setting_messages_uber()
        case .Ola: return R.string.localizable.setting_messages_ola()
        case .ReflexApp: return R.string.localizable.setting_messages_reflexapp()
        case .Snapchat: return R.string.localizable.setting_messages_snapchat()
        case .YtMusic: return R.string.localizable.setting_messages_ytmusic()
        case .YouTube: return R.string.localizable.setting_messages_youtube()
        case .LinkEdin: return R.string.localizable.setting_messages_linkedin()
        case .Amazon: return R.string.localizable.setting_messages_amazon()
        case .Flipkart: return R.string.localizable.setting_messages_flipkarta()
        case .NetFlix: return R.string.localizable.setting_messages_netflix()
        case .Hotstar: return R.string.localizable.setting_messages_hotstar()
        case .AmazonPrime: return R.string.localizable.setting_messages_amazonprime()
        case .GoogleChat: return R.string.localizable.setting_messages_googlechat()
        case .Wynk: return R.string.localizable.setting_messages_wynk()
        case .GoogleDrive: return R.string.localizable.setting_messages_googledrive()
        case .Dunzo: return R.string.localizable.setting_messages_dunzo()
        case .Gaana: return R.string.localizable.setting_messages_gaana()
        case .MissCall: return R.string.localizable.setting_messages_misscall()
        case .WhatsAppBussiness: return R.string.localizable.setting_messages_whatsappbussiness()
        case .Dingtalk: return R.string.localizable.setting_messages_dingtalk()
        case .Tiktok: return R.string.localizable.setting_messages_tiktok()
        case .Lyft: return R.string.localizable.setting_messages_lyft()
        case .Mail: return R.string.localizable.setting_messages_mail()
        case .GoogleMaps: return R.string.localizable.setting_messages_googlemaps()
        case .Slack: return R.string.localizable.setting_messages_slack()
        case .MicrosoftTeams: return R.string.localizable.setting_messages_microsoftteams()
        case .MormaiiSmartwatches: return R.string.localizable.setting_messages_mormaiismartwatches()
        case .Reddit: return R.string.localizable.setting_messages_reddit()
        case .Discord: return R.string.localizable.setting_messages_discord()
        case .Calendar: return R.string.localizable.setting_messages_apple_calendar()
        case .Gojek: return R.string.localizable.setting_messages_gojek()
        case .Lark: return R.string.localizable.setting_messages_lark()
        case .Garb: return R.string.localizable.setting_messages_garb()
        case .Shopee: return R.string.localizable.setting_messages_shopee()
        case .Tokopedia: return R.string.localizable.setting_messages_tokopedia()
        case .other: return R.string.localizable.setting_messages_other()
        }
    }
    
}
